package com.bw.search.server.controller;

import com.bw.common.core.domain.Result;
import com.bw.search.server.service.EsService;
import com.bw.search.server.vo.SearchParam;
import com.bw.search.server.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sku")
public class EsSearchController {

    @Autowired
    private EsService esService;
    @GetMapping("/list")
    public Result<SearchResult> searchResultResult(SearchParam searchParam){

        try {
            SearchResult search = esService.search(searchParam);
            return Result.success(search);
        } catch (Exception e) {
            return Result.error(e.getMessage());
        }

    }

}
